package game

import (
	"encoding/json"
	. "github.com/kadycui/web/model"
	"log"
	"sync"
)

func SyncGm(requestBody []byte) {

	// 使用 WaitGroup 进行任务同步
	var wg sync.WaitGroup
	var ra RequestArray
	err := json.Unmarshal(requestBody, &ra)
	if err != nil {
		panic(err.Error())
	}

	for i, item := range ra {
		if err != nil {
			log.Panic("转换失败:", err)
			return
		}
		gmp := GmProtocol{
			Number:    ACTIVITY,
			ServerId:  45,
			Host:      "10.16.168.54",
			Port:      12453,
			PlayerIDs: []int64{47185924, 47185924},
			Data:      item,
		}
		wg.Add(1)
		go gmp.SendGmServer(i+1, &wg)
	}
}
